﻿using System;
using System.Windows.Forms;


namespace TextGenerator
{
    public partial class MainForm : Form
    {
        private void rtbResults_KeyDown(object sender, KeyEventArgs e)
        {
           // Make sure Control is pressed.
            if (!e.Control)
                return;

            // Get the control.
            RichTextBox rtb = (RichTextBox)sender;

            // Determine what key was pressed.
            switch (e.KeyCode)
            {
                case Keys.C:
                    // Copy the text without formatting.

                    // Don't do anything if nothing is selected.
                    if (String.IsNullOrEmpty(rtb.SelectedText))
                        return;

                    // Set the clipboard's text.
                    Clipboard.SetText(rtb.SelectedText, TextDataFormat.Text);

                    // Tag the event as handled, 
                    // and suppress the key press as no more processing is needed.
                    e.Handled = true;
                    e.SuppressKeyPress = true;
                    break;
                case Keys.Z:
                    // Ignore the Undo-shortcut.
                    e.Handled = true;
                    e.SuppressKeyPress = true;
                    break;
                default:
                    return;
            }
        }
    }
}